#j'importe les librairies qui vont me servir plus tard
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.io as pio
#Je definis le nombre de lignes max affichées sur None
pd.set_option("max_rows", None)
pd.set_option("display.precision",7)
#pd.options.display.int64_format='{:,}'.format
#'{:,}'.format(1234567890.001).replace(',', ' ')
#Je charge tous les fichiers csv
data_p8_1tour = pd.read_csv("C:/Users/33643/Desktop/P8 perso/election-presidentielle-2017-resultats-par-bureaux-de-vote-tour-1.csv",sep=';',encoding='utf-8-sig',decimal=".")
#J'affiche une phrase si l'import est reussi
print("Fichiers chargés avec succes!")
Fichiers chargés avec succes!
data_p8_1tour.head()
| Code du département | Département | Code de la circonscription | Circonscription | Code de la commune | Commune | Bureau de vote | Inscrits | Abstentions | % Abs/Ins | ... | Voix | % Voix/Ins | % Voix/Exp | Code Insee | Coordonnées | Nom Bureau Vote | Adresse | Code Postal | Ville | uniq_bdv | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 77 | Seine-et-Marne | 7 | 7ème circonscription | 438 | Saint-Thibault-des-Vignes | 0003 | 1063 | 283 | 26.62 | ... | 101 | 9.50 | 13.32 | 77438 | 48.854007,2.668821 | Groupe scolaire Marie Curie | 26 rue de l'Etang de la Loy | 77400.0 | Saint-Thibault-des-Vignes | Groupe scolaire Marie Curie - Saint-Thibault-... |
| 1 | 38 | Isère | 5 | 5ème circonscription | 2 | Les Adrets | 0001 | 779 | 106 | 13.61 | ... | 7 | 0.90 | 1.06 | 38002 | 45.271187,5.964303 | Mairie | NaN | 38190.0 | Les Adrets | Mairie - Les Adrets |
| 2 | 52 | Haute-Marne | 2 | 2ème circonscription | 331 | La Porte du Der | 0001 | 1383 | 295 | 21.33 | ... | 198 | 14.32 | 18.66 | 52331 | 48.476677,4.771312 | Halle au blé | 10 place de l’Hôtel de ville | 52220.0 | La Porte du Der | Halle au blé - La Porte du Der |
| 3 | 2B | Haute-Corse | 1 | 1ère circonscription | 33 | Bastia | 0022 | 1175 | 328 | 27.91 | ... | 0 | 0.00 | 0.00 | 2B033 | NaN | NaN | NaN | NaN | NaN | NaN |
| 4 | 83 | Var | 6 | 6ème circonscription | 16 | Le Beausset | 0007 | 869 | 149 | 17.15 | ... | 2 | 0.23 | 0.28 | 83016 | 43.196343,5.796027 | Réféctoire de l'école maternelle Pagnol | Avenue des Tilleuls | 83330.0 | Le Beausset | Réféctoire de l'école maternelle Pagnol - Le ... |
5 rows × 35 columns
data_p8_1tour.dtypes
Code du département object Département object Code de la circonscription int64 Circonscription object Code de la commune int64 Commune object Bureau de vote object Inscrits int64 Abstentions int64 % Abs/Ins float64 Votants int64 % Vot/Ins float64 Blancs int64 % Blancs/Ins float64 % Blancs/Vot float64 Nuls int64 % Nuls/Ins float64 % Nuls/Vot float64 Exprimés int64 % Exp/Ins float64 % Exp/Vot float64 N°Panneau int64 Sexe object Nom object Prénom object Voix int64 % Voix/Ins float64 % Voix/Exp float64 Code Insee object Coordonnées object Nom Bureau Vote object Adresse object Code Postal float64 Ville object uniq_bdv object dtype: object
data_p8_1tour.describe()
| Code de la circonscription | Code de la commune | Inscrits | Abstentions | % Abs/Ins | Votants | % Vot/Ins | Blancs | % Blancs/Ins | % Blancs/Vot | ... | % Nuls/Ins | % Nuls/Vot | Exprimés | % Exp/Ins | % Exp/Vot | N°Panneau | Voix | % Voix/Ins | % Voix/Exp | Code Postal | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | ... | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 761805.0000000 | 669790.0000000 |
| mean | 4.1726374 | 233.8972926 | 687.1699083 | 152.7664862 | 20.2658724 | 534.4034221 | 79.7327155 | 9.5314418 | 1.4843600 | 1.9010008 | ... | 0.6642203 | 0.8900908 | 520.6931052 | 77.5841268 | 97.2060318 | 6.0000000 | 47.3357368 | 7.0530994 | 9.0890722 | 50536.9147151 |
| std | 3.2820111 | 184.0974465 | 869.1093531 | 438.2692236 | 9.4789718 | 484.5794025 | 9.4835036 | 7.2850440 | 0.9585476 | 1.3549837 | ... | 1.2315544 | 1.7700098 | 477.9364300 | 9.6778536 | 2.3939468 | 3.1622797 | 91.6637283 | 8.3825747 | 10.6890078 | 26352.3430231 |
| min | 1.0000000 | 1.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | ... | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 1.0000000 | 0.0000000 | 0.0000000 | 0.0000000 | 1000.0000000 |
| 25% | 2.0000000 | 81.0000000 | 283.0000000 | 46.0000000 | 14.8600000 | 228.0000000 | 77.2400000 | 4.0000000 | 0.9200000 | 1.1600000 | ... | 0.2100000 | 0.2700000 | 220.0000000 | 75.1700000 | 96.7300000 | 3.0000000 | 3.0000000 | 0.5500000 | 0.7300000 | 29460.0000000 |
| 50% | 3.0000000 | 192.0000000 | 743.0000000 | 132.0000000 | 18.1900000 | 570.0000000 | 81.8100000 | 9.0000000 | 1.3800000 | 1.7400000 | ... | 0.4900000 | 0.6200000 | 554.0000000 | 79.6600000 | 97.5400000 | 6.0000000 | 12.0000000 | 2.9700000 | 3.8700000 | 53000.0000000 |
| 75% | 5.0000000 | 346.0000000 | 967.0000000 | 206.0000000 | 22.7600000 | 762.0000000 | 85.1400000 | 14.0000000 | 1.9000000 | 2.3800000 | ... | 0.8400000 | 1.0600000 | 744.0000000 | 83.0100000 | 98.2100000 | 9.0000000 | 62.0000000 | 12.8400000 | 16.6700000 | 72000.0000000 |
| max | 21.0000000 | 909.0000000 | 105891.0000000 | 49721.0000000 | 100.0000000 | 56216.0000000 | 100.0000000 | 382.0000000 | 20.0000000 | 37.5000000 | ... | 89.3900000 | 100.0000000 | 55580.0000000 | 100.0000000 | 100.0000000 | 11.0000000 | 22385.0000000 | 84.2100000 | 96.5500000 | 95880.0000000 |
8 rows × 21 columns
#Je verifie le nombre de lignes et de colonnes
data_p8_1tour.shape
(761805, 35)
#J'affiche le nom des colonnes
data_p8_1tour.columns
Index(['Code du département', 'Département', 'Code de la circonscription',
'Circonscription', 'Code de la commune', 'Commune', 'Bureau de vote',
'Inscrits', 'Abstentions', '% Abs/Ins', 'Votants', '% Vot/Ins',
'Blancs', '% Blancs/Ins', '% Blancs/Vot', 'Nuls', '% Nuls/Ins',
'% Nuls/Vot', 'Exprimés', '% Exp/Ins', '% Exp/Vot', 'N°Panneau', 'Sexe',
'Nom', 'Prénom', 'Voix', '% Voix/Ins', '% Voix/Exp', 'Code Insee',
'Coordonnées', 'Nom Bureau Vote', 'Adresse', 'Code Postal', 'Ville',
'uniq_bdv'],
dtype='object')
#Je supprime les colonnes non utiles
data_p8_1tour = data_p8_1tour.drop(columns =['N°Panneau','Code Insee','Coordonnées','Nom Bureau Vote','Adresse','Ville','uniq_bdv','Code Postal'])
data_p8_1tour.head()
| Code du département | Département | Code de la circonscription | Circonscription | Code de la commune | Commune | Bureau de vote | Inscrits | Abstentions | % Abs/Ins | ... | % Nuls/Vot | Exprimés | % Exp/Ins | % Exp/Vot | Sexe | Nom | Prénom | Voix | % Voix/Ins | % Voix/Exp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 77 | Seine-et-Marne | 7 | 7ème circonscription | 438 | Saint-Thibault-des-Vignes | 0003 | 1063 | 283 | 26.62 | ... | 0.90 | 758 | 71.31 | 97.18 | M | FILLON | François | 101 | 9.50 | 13.32 |
| 1 | 38 | Isère | 5 | 5ème circonscription | 2 | Les Adrets | 0001 | 779 | 106 | 13.61 | ... | 0.45 | 662 | 84.98 | 98.37 | M | POUTOU | Philippe | 7 | 0.90 | 1.06 |
| 2 | 52 | Haute-Marne | 2 | 2ème circonscription | 331 | La Porte du Der | 0001 | 1383 | 295 | 21.33 | ... | 0.46 | 1061 | 76.72 | 97.52 | M | FILLON | François | 198 | 14.32 | 18.66 |
| 3 | 2B | Haute-Corse | 1 | 1ère circonscription | 33 | Bastia | 0022 | 1175 | 328 | 27.91 | ... | 1.42 | 826 | 70.30 | 97.52 | F | ARTHAUD | Nathalie | 0 | 0.00 | 0.00 |
| 4 | 83 | Var | 6 | 6ème circonscription | 16 | Le Beausset | 0007 | 869 | 149 | 17.15 | ... | 0.69 | 708 | 81.47 | 98.33 | F | ARTHAUD | Nathalie | 2 | 0.23 | 0.28 |
5 rows × 27 columns
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZA', 971)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZB', 972)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZC', 973)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZD', 974)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZM', 976)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZN', 988)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZP', 987)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZS', 975)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZW', 986)
data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZX', 978)
#data_p8_1tour['Code du département'] = data_p8_1tour['Code du département'].replace('ZZ', 988)
departements = data_p8_1tour.groupby(['Code du département','Département']).sum()
departements = departements.drop(columns =['Code de la circonscription','Code de la commune','Inscrits','Abstentions','% Abs/Ins','Votants','% Vot/Ins','Blancs'])
departements = departements.drop(columns =['% Blancs/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
departements
| Code du département | Département |
|---|---|
| 971 | Guadeloupe |
| 972 | Martinique |
| 973 | Guyane |
| 974 | La Réunion |
| 975 | Saint-Pierre-et-Miquelon |
| 976 | Mayotte |
| 978 | Saint-Martin/Saint-Barthélemy |
| 986 | Wallis et Futuna |
| 987 | Polynésie française |
| 988 | Nouvelle-Calédonie |
| 01 | Ain |
| 02 | Aisne |
| 03 | Allier |
| 04 | Alpes-de-Haute-Provence |
| 05 | Hautes-Alpes |
| 06 | Alpes-Maritimes |
| 07 | Ardèche |
| 08 | Ardennes |
| 09 | Ariège |
| 10 | Aube |
| 11 | Aude |
| 12 | Aveyron |
| 13 | Bouches-du-Rhône |
| 14 | Calvados |
| 15 | Cantal |
| 16 | Charente |
| 17 | Charente-Maritime |
| 18 | Cher |
| 19 | Corrèze |
| 21 | Côte-d'Or |
| 22 | Côtes-d'Armor |
| 23 | Creuse |
| 24 | Dordogne |
| 25 | Doubs |
| 26 | Drôme |
| 27 | Eure |
| 28 | Eure-et-Loir |
| 29 | Finistère |
| 2A | Corse-du-Sud |
| 2B | Haute-Corse |
| 30 | Gard |
| 31 | Haute-Garonne |
| 32 | Gers |
| 33 | Gironde |
| 34 | Hérault |
| 35 | Ille-et-Vilaine |
| 36 | Indre |
| 37 | Indre-et-Loire |
| 38 | Isère |
| 39 | Jura |
| 40 | Landes |
| 41 | Loir-et-Cher |
| 42 | Loire |
| 43 | Haute-Loire |
| 44 | Loire-Atlantique |
| 45 | Loiret |
| 46 | Lot |
| 47 | Lot-et-Garonne |
| 48 | Lozère |
| 49 | Maine-et-Loire |
| 50 | Manche |
| 51 | Marne |
| 52 | Haute-Marne |
| 53 | Mayenne |
| 54 | Meurthe-et-Moselle |
| 55 | Meuse |
| 56 | Morbihan |
| 57 | Moselle |
| 58 | Nièvre |
| 59 | Nord |
| 60 | Oise |
| 61 | Orne |
| 62 | Pas-de-Calais |
| 63 | Puy-de-Dôme |
| 64 | Pyrénées-Atlantiques |
| 65 | Hautes-Pyrénées |
| 66 | Pyrénées-Orientales |
| 67 | Bas-Rhin |
| 68 | Haut-Rhin |
| 69 | Rhône |
| 70 | Haute-Saône |
| 71 | Saône-et-Loire |
| 72 | Sarthe |
| 73 | Savoie |
| 74 | Haute-Savoie |
| 75 | Paris |
| 76 | Seine-Maritime |
| 77 | Seine-et-Marne |
| 78 | Yvelines |
| 79 | Deux-Sèvres |
| 80 | Somme |
| 81 | Tarn |
| 82 | Tarn-et-Garonne |
| 83 | Var |
| 84 | Vaucluse |
| 85 | Vendée |
| 86 | Vienne |
| 87 | Haute-Vienne |
| 88 | Vosges |
| 89 | Yonne |
| 90 | Territoire de Belfort |
| 91 | Essonne |
| 92 | Hauts-de-Seine |
| 93 | Seine-Saint-Denis |
| 94 | Val-de-Marne |
| 95 | Val-d'Oise |
| ZZ | Français établis hors de France |
print(data_p8_1tour.isnull().any())
print(data_p8_1tour.isnull().sum())
Code du département False Département False Code de la circonscription False Circonscription False Code de la commune False Commune False Bureau de vote False Inscrits False Abstentions False % Abs/Ins False Votants False % Vot/Ins False Blancs False % Blancs/Ins False % Blancs/Vot False Nuls False % Nuls/Ins False % Nuls/Vot False Exprimés False % Exp/Ins False % Exp/Vot False Sexe False Nom False Prénom False Voix False % Voix/Ins False % Voix/Exp False dtype: bool Code du département 0 Département 0 Code de la circonscription 0 Circonscription 0 Code de la commune 0 Commune 0 Bureau de vote 0 Inscrits 0 Abstentions 0 % Abs/Ins 0 Votants 0 % Vot/Ins 0 Blancs 0 % Blancs/Ins 0 % Blancs/Vot 0 Nuls 0 % Nuls/Ins 0 % Nuls/Vot 0 Exprimés 0 % Exp/Ins 0 % Exp/Vot 0 Sexe 0 Nom 0 Prénom 0 Voix 0 % Voix/Ins 0 % Voix/Exp 0 dtype: int64
data_p8_1tour.head()
| Code du département | Département | Code de la circonscription | Circonscription | Code de la commune | Commune | Bureau de vote | Inscrits | Abstentions | % Abs/Ins | ... | % Nuls/Vot | Exprimés | % Exp/Ins | % Exp/Vot | Sexe | Nom | Prénom | Voix | % Voix/Ins | % Voix/Exp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 77 | Seine-et-Marne | 7 | 7ème circonscription | 438 | Saint-Thibault-des-Vignes | 0003 | 1063 | 283 | 26.62 | ... | 0.90 | 758 | 71.31 | 97.18 | M | FILLON | François | 101 | 9.50 | 13.32 |
| 1 | 38 | Isère | 5 | 5ème circonscription | 2 | Les Adrets | 0001 | 779 | 106 | 13.61 | ... | 0.45 | 662 | 84.98 | 98.37 | M | POUTOU | Philippe | 7 | 0.90 | 1.06 |
| 2 | 52 | Haute-Marne | 2 | 2ème circonscription | 331 | La Porte du Der | 0001 | 1383 | 295 | 21.33 | ... | 0.46 | 1061 | 76.72 | 97.52 | M | FILLON | François | 198 | 14.32 | 18.66 |
| 3 | 2B | Haute-Corse | 1 | 1ère circonscription | 33 | Bastia | 0022 | 1175 | 328 | 27.91 | ... | 1.42 | 826 | 70.30 | 97.52 | F | ARTHAUD | Nathalie | 0 | 0.00 | 0.00 |
| 4 | 83 | Var | 6 | 6ème circonscription | 16 | Le Beausset | 0007 | 869 | 149 | 17.15 | ... | 0.69 | 708 | 81.47 | 98.33 | F | ARTHAUD | Nathalie | 2 | 0.23 | 0.28 |
5 rows × 27 columns
print(data_p8_1tour.duplicated().any())
print(data_p8_1tour.duplicated().sum())
True 143
data_p8_1tour[data_p8_1tour.duplicated()]
| Code du département | Département | Code de la circonscription | Circonscription | Code de la commune | Commune | Bureau de vote | Inscrits | Abstentions | % Abs/Ins | ... | % Nuls/Vot | Exprimés | % Exp/Ins | % Exp/Vot | Sexe | Nom | Prénom | Voix | % Voix/Ins | % Voix/Exp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 58748 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | POUTOU | Philippe | 9 | 2.12 | 2.57 |
| 130012 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | MACRON | Emmanuel | 85 | 23.74 | 29.21 |
| 156719 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | F | LE PEN | Marine | 49 | 13.69 | 16.33 |
| 162142 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | HAMON | Benoît | 9 | 4.15 | 4.76 |
| 179612 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | POUTOU | Philippe | 9 | 0.78 | 0.94 |
| 181850 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | F | LE PEN | Marine | 53 | 22.84 | 28.49 |
| 184399 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | ASSELINEAU | François | 10 | 0.93 | 1.18 |
| 196605 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | ASSELINEAU | François | 9 | 0.60 | 0.79 |
| 201793 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | POUTOU | Philippe | 1 | 0.28 | 0.34 |
| 208909 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | ASSELINEAU | François | 2 | 0.56 | 0.67 |
| 212733 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | F | ARTHAUD | Nathalie | 17 | 1.13 | 1.49 |
| 224668 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | DUPONT-AIGNAN | Nicolas | 9 | 2.51 | 3.09 |
| 225124 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | ASSELINEAU | François | 1 | 0.25 | 0.30 |
| 227963 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | MACRON | Emmanuel | 78 | 15.51 | 19.95 |
| 235729 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | F | ARTHAUD | Nathalie | 8 | 0.69 | 0.84 |
| 250669 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | HAMON | Benoît | 15 | 2.63 | 3.57 |
| 259478 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | ASSELINEAU | François | 5 | 0.99 | 1.28 |
| 269338 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | LASSALLE | Jean | 10 | 4.61 | 5.29 |
| 270338 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | MACRON | Emmanuel | 100 | 14.49 | 18.08 |
| 274150 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | CHEMINADE | Jacques | 0 | 0.00 | 0.00 |
| 278400 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | CHEMINADE | Jacques | 2 | 0.17 | 0.21 |
| 289885 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | MÉLENCHON | Jean-Luc | 105 | 18.39 | 25.00 |
| 298135 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | HAMON | Benoît | 29 | 8.10 | 9.67 |
| 302875 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | F | LE PEN | Marine | 97 | 22.88 | 27.71 |
| 328551 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | HAMON | Benoît | 49 | 3.26 | 4.28 |
| 352620 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | HAMON | Benoît | 30 | 7.61 | 9.09 |
| 354712 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | MÉLENCHON | Jean-Luc | 60 | 14.15 | 17.14 |
| 356753 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | CHEMINADE | Jacques | 3 | 0.28 | 0.35 |
| 372537 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | DUPONT-AIGNAN | Nicolas | 17 | 6.01 | 6.80 |
| 374144 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | POUTOU | Philippe | 4 | 1.02 | 1.21 |
| 379556 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | MACRON | Emmanuel | 92 | 23.35 | 27.88 |
| 382706 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | ASSELINEAU | François | 4 | 0.35 | 0.42 |
| 384096 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | MÉLENCHON | Jean-Luc | 129 | 8.57 | 11.28 |
| 387750 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | MÉLENCHON | Jean-Luc | 39 | 16.81 | 20.97 |
| 396105 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | CHEMINADE | Jacques | 1 | 0.35 | 0.40 |
| 397945 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | HAMON | Benoît | 18 | 4.25 | 5.14 |
| 402061 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | FILLON | François | 67 | 11.73 | 15.95 |
| 402615 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | LASSALLE | Jean | 20 | 1.86 | 2.36 |
| 405879 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | F | LE PEN | Marine | 88 | 17.50 | 22.51 |
| 406758 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | ASSELINEAU | François | 4 | 0.70 | 0.95 |
| 409633 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | ASSELINEAU | François | 1 | 0.46 | 0.53 |
| 414811 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | ASSELINEAU | François | 1 | 0.14 | 0.18 |
| 420160 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | DUPONT-AIGNAN | Nicolas | 50 | 4.33 | 5.23 |
| 423639 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | LASSALLE | Jean | 14 | 4.95 | 5.60 |
| 429403 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | LASSALLE | Jean | 13 | 3.63 | 4.33 |
| 438411 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | POUTOU | Philippe | 6 | 0.56 | 0.71 |
| 439518 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | FILLON | François | 350 | 23.26 | 30.59 |
| 439959 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | LASSALLE | Jean | 9 | 2.12 | 2.57 |
| 443570 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | DUPONT-AIGNAN | Nicolas | 15 | 4.19 | 5.00 |
| 449396 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | DUPONT-AIGNAN | Nicolas | 13 | 3.30 | 3.94 |
| 449468 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | CHEMINADE | Jacques | 1 | 0.25 | 0.30 |
| 452311 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | HAMON | Benoît | 22 | 7.77 | 8.80 |
| 452677 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | POUTOU | Philippe | 1 | 0.28 | 0.33 |
| 456316 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | CHEMINADE | Jacques | 1 | 0.28 | 0.33 |
| 457258 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | MÉLENCHON | Jean-Luc | 43 | 19.82 | 22.75 |
| 457599 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | MÉLENCHON | Jean-Luc | 197 | 17.04 | 20.61 |
| 463531 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | MÉLENCHON | Jean-Luc | 103 | 14.93 | 18.63 |
| 467102 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | F | LE PEN | Marine | 224 | 14.88 | 19.58 |
| 471910 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | F | ARTHAUD | Nathalie | 3 | 0.53 | 0.71 |
| 478063 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | HAMON | Benoît | 7 | 3.02 | 3.76 |
| 479033 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | F | LE PEN | Marine | 223 | 19.29 | 23.33 |
| 481998 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | ASSELINEAU | François | 0 | 0.00 | 0.00 |
| 484847 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | FILLON | François | 67 | 17.01 | 20.30 |
| 489128 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | DUPONT-AIGNAN | Nicolas | 30 | 4.35 | 5.42 |
| 491127 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | DUPONT-AIGNAN | Nicolas | 23 | 4.03 | 5.48 |
| 492545 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | F | LE PEN | Marine | 53 | 14.80 | 18.21 |
| 499356 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | LASSALLE | Jean | 5 | 0.88 | 1.19 |
| 500043 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | LASSALLE | Jean | 6 | 1.68 | 2.06 |
| 502751 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | F | LE PEN | Marine | 129 | 22.59 | 30.71 |
| 507167 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | DUPONT-AIGNAN | Nicolas | 49 | 4.55 | 5.79 |
| 507808 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | F | ARTHAUD | Nathalie | 1 | 0.25 | 0.30 |
| 508939 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | MÉLENCHON | Jean-Luc | 72 | 20.11 | 24.00 |
| 515805 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | FILLON | François | 44 | 12.29 | 15.12 |
| 519292 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | HAMON | Benoît | 61 | 5.66 | 7.20 |
| 519710 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | F | ARTHAUD | Nathalie | 1 | 0.28 | 0.34 |
| 521129 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | LASSALLE | Jean | 0 | 0.00 | 0.00 |
| 525846 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | POUTOU | Philippe | 3 | 0.43 | 0.54 |
| 541800 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | FILLON | François | 99 | 9.18 | 11.69 |
| 548636 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | LASSALLE | Jean | 13 | 3.30 | 3.94 |
| 551139 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | POUTOU | Philippe | 19 | 1.26 | 1.66 |
| 552476 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | LASSALLE | Jean | 7 | 1.01 | 1.27 |
| 555106 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | MACRON | Emmanuel | 51 | 23.50 | 26.98 |
| 562429 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | CHEMINADE | Jacques | 2 | 0.47 | 0.57 |
| 565444 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | HAMON | Benoît | 26 | 7.26 | 8.93 |
| 568778 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | MÉLENCHON | Jean-Luc | 64 | 17.88 | 21.99 |
| 571400 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | F | LE PEN | Marine | 69 | 24.38 | 27.60 |
| 574382 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | POUTOU | Philippe | 3 | 1.29 | 1.61 |
| 585890 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | HAMON | Benoît | 59 | 5.10 | 6.17 |
| 586298 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | FILLON | François | 67 | 13.32 | 17.14 |
| 589875 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | POUTOU | Philippe | 6 | 1.19 | 1.53 |
| 591610 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | M | MÉLENCHON | Jean-Luc | 58 | 14.72 | 17.58 |
| 597498 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | MÉLENCHON | Jean-Luc | 89 | 17.69 | 22.76 |
| 598472 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | MACRON | Emmanuel | 58 | 16.20 | 19.33 |
| 598828 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | HAMON | Benoît | 25 | 4.97 | 6.39 |
| 601826 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | MACRON | Emmanuel | 63 | 11.03 | 15.00 |
| 603214 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | MÉLENCHON | Jean-Luc | 197 | 18.27 | 23.26 |
| 608034 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | ASSELINEAU | François | 2 | 0.71 | 0.80 |
| 618313 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | MACRON | Emmanuel | 43 | 15.19 | 17.20 |
| 619736 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | DUPONT-AIGNAN | Nicolas | 9 | 2.12 | 2.57 |
| 622532 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | DUPONT-AIGNAN | Nicolas | 5 | 2.30 | 2.65 |
| 622950 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | CHEMINADE | Jacques | 0 | 0.00 | 0.00 |
| 624893 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | F | ARTHAUD | Nathalie | 3 | 1.29 | 1.61 |
| 625116 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | MACRON | Emmanuel | 240 | 20.76 | 25.10 |
| 626647 | 46 | Lot | 1 | 1ère circonscription | 156 | Bellefont-La Rauze | 0001 | 394 | 57 | 14.47 | ... | 0.89 | 330 | 83.76 | 97.92 | F | LE PEN | Marine | 50 | 12.69 | 15.15 |
| 632121 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | MACRON | Emmanuel | 273 | 18.14 | 23.86 |
| 637008 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | CHEMINADE | Jacques | 0 | 0.00 | 0.00 |
| 644529 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | CHEMINADE | Jacques | 1 | 0.18 | 0.24 |
| 645866 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | M | FILLON | François | 59 | 16.48 | 19.67 |
| 649964 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | FILLON | François | 51 | 21.98 | 27.42 |
| 652538 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | FILLON | François | 105 | 15.22 | 18.99 |
| 655735 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | POUTOU | Philippe | 1 | 0.46 | 0.53 |
| 658780 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | M | MACRON | Emmanuel | 206 | 19.11 | 24.32 |
| 660339 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | FILLON | François | 50 | 11.79 | 14.29 |
| 660884 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | DUPONT-AIGNAN | Nicolas | 17 | 3.38 | 4.35 |
| 665818 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | F | ARTHAUD | Nathalie | 1 | 0.24 | 0.29 |
| 668196 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | F | ARTHAUD | Nathalie | 3 | 1.38 | 1.59 |
| 674017 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | F | LE PEN | Marine | 151 | 21.88 | 27.31 |
| 676332 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | F | ARTHAUD | Nathalie | 3 | 0.60 | 0.77 |
| 676393 | 63 | Puy-de-Dôme | 2 | 2ème circonscription | 244 | Chambaron-sur-Morge | 0001 | 424 | 62 | 14.62 | ... | 0.28 | 350 | 82.55 | 96.69 | M | MACRON | Emmanuel | 95 | 22.41 | 27.14 |
| 684730 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | CHEMINADE | Jacques | 2 | 0.29 | 0.36 |
| 690249 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | FILLON | François | 54 | 19.08 | 21.60 |
| 691336 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | LASSALLE | Jean | 11 | 2.19 | 2.81 |
| 691466 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | F | LE PEN | Marine | 42 | 19.35 | 22.22 |
| 696052 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | MÉLENCHON | Jean-Luc | 23 | 8.13 | 9.20 |
| 705991 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | LASSALLE | Jean | 15 | 1.30 | 1.57 |
| 711360 | 31 | Haute-Garonne | 5 | 5ème circonscription | 205 | Gagnac-sur-Garonne | 0001 | 1156 | 170 | 14.71 | ... | 1.42 | 956 | 82.70 | 96.96 | M | FILLON | François | 149 | 12.89 | 15.59 |
| 716008 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | DUPONT-AIGNAN | Nicolas | 10 | 4.31 | 5.38 |
| 716725 | 18 | Cher | 3 | 3ème circonscription | 58 | Châteauneuf-sur-Cher | 0001 | 571 | 142 | 24.87 | ... | 0.23 | 420 | 73.56 | 97.90 | M | POUTOU | Philippe | 5 | 0.88 | 1.19 |
| 720640 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | F | ARTHAUD | Nathalie | 2 | 0.71 | 0.80 |
| 722882 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | F | ARTHAUD | Nathalie | 1 | 0.14 | 0.18 |
| 727998 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | F | LE PEN | Marine | 195 | 18.09 | 23.02 |
| 728807 | 33 | Gironde | 8 | 8ème circonscription | 555 | Marcheprime | 0001 | 1078 | 209 | 19.39 | ... | 1.38 | 847 | 78.57 | 97.47 | F | ARTHAUD | Nathalie | 1 | 0.09 | 0.12 |
| 734228 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | CHEMINADE | Jacques | 2 | 0.13 | 0.17 |
| 735121 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | ASSELINEAU | François | 1 | 0.43 | 0.54 |
| 738395 | 80 | Somme | 5 | 5ème circonscription | 230 | Curchy | 0001 | 232 | 44 | 18.97 | ... | 0.00 | 186 | 80.17 | 98.94 | M | MACRON | Emmanuel | 19 | 8.19 | 10.22 |
| 740589 | 65 | Hautes-Pyrénées | 1 | 1ère circonscription | 84 | Bernac-Dessus | 0001 | 217 | 24 | 11.06 | ... | 0.52 | 189 | 87.10 | 97.93 | M | FILLON | François | 24 | 11.06 | 12.70 |
| 741014 | 22 | Côtes-d'Armor | 3 | 3ème circonscription | 183 | Les Moulins | 0001 | 690 | 124 | 17.97 | ... | 0.53 | 553 | 80.14 | 97.70 | M | HAMON | Benoît | 50 | 7.25 | 9.04 |
| 745838 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | LASSALLE | Jean | 8 | 0.53 | 0.70 |
| 751637 | 43 | Haute-Loire | 2 | 2ème circonscription | 187 | Saint-Geneys-près-Saint-Paulien | 0001 | 283 | 28 | 9.89 | ... | 1.57 | 250 | 88.34 | 98.04 | M | POUTOU | Philippe | 3 | 1.06 | 1.20 |
| 753695 | 23 | Creuse | 1 | 1ère circonscription | 149 | Parsac-Rimondeix | 0001 | 503 | 100 | 19.88 | ... | 1.74 | 391 | 77.73 | 97.02 | M | CHEMINADE | Jacques | 2 | 0.40 | 0.51 |
| 754496 | 50 | Manche | 2 | 2ème circonscription | 484 | Saint-Hilaire-du-Harcouët | 0001 | 1505 | 316 | 21.00 | ... | 1.26 | 1144 | 76.01 | 96.22 | M | DUPONT-AIGNAN | Nicolas | 64 | 4.25 | 5.59 |
| 755191 | 46 | Lot | 1 | 1ère circonscription | 103 | Saint-Paul-Flaugnac | 0001 | 358 | 54 | 15.08 | ... | 0.66 | 300 | 83.80 | 98.68 | F | ARTHAUD | Nathalie | 1 | 0.28 | 0.33 |
| 761680 | 46 | Lot | 1 | 1ère circonscription | 268 | Saint Géry-Vers | 0001 | 358 | 58 | 16.20 | ... | 2.67 | 291 | 81.28 | 97.00 | M | ASSELINEAU | François | 2 | 0.56 | 0.69 |
143 rows × 27 columns
codes_departement = len(data_p8_1tour['Code du département'].unique())
codes_departement
107
circonscriptions = len(data_p8_1tour['Circonscription'].unique())
circonscriptions
22
communes = len(data_p8_1tour['Commune'].unique())
communes
33363
bureaux = len(data_p8_1tour['Bureau de vote'].unique())
bureaux
1727
nbr_candidats = len(data_p8_1tour['Nom'].unique())
nbr_candidats
11
#Jé crée un dataframe pour le résumé des données
résumé_données = pd.DataFrame({'Nombre': pd.Series([codes_departement, circonscriptions, communes,bureaux,nbr_candidats], index = ['départements', 'circonscriptions', 'communes','bureaux_de_vote','candidats'])})
résumé_données
| Nombre | |
|---|---|
| départements | 107 |
| circonscriptions | 22 |
| communes | 33363 |
| bureaux_de_vote | 1727 |
| candidats | 11 |
participation = data_p8_1tour.groupby('Nom').sum()
participation = participation.reset_index(drop=False)
participation.head(2)
| Nom | Code de la circonscription | Code de la commune | Inscrits | Abstentions | % Abs/Ins | Votants | % Vot/Ins | Blancs | % Blancs/Ins | % Blancs/Vot | Nuls | % Nuls/Ins | % Nuls/Vot | Exprimés | % Exp/Ins | % Exp/Vot | Voix | % Voix/Ins | % Voix/Exp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ARTHAUD | 288976 | 16198557 | 47589952 | 10579843 | 1403512.99 | 37010109 | 5521889.21 | 660100 | 102799.35 | 131653.81 | 289408 | 46000.58 | 61643.24 | 36060601 | 5373088.7 | 6.7320037e+06 | 232429 | 37347.82 | 49472.11 |
| 1 | ASSELINEAU | 288976 | 16198557 | 47589952 | 10579843 | 1403512.99 | 37010109 | 5521889.21 | 660100 | 102799.35 | 131653.81 | 289408 | 46000.58 | 61643.24 | 36060601 | 5373088.7 | 6.7320037e+06 | 332589 | 48254.59 | 63619.26 |
inscrits_sum = participation.loc[participation['Nom'] == 'ARTHAUD','Inscrits']
inscrits_sum = inscrits_sum.to_string(index = False)
inscrits_sum
'47589952'
absentions_sum = participation.loc[participation['Nom'] == 'ARTHAUD','Abstentions']
absentions_sum = absentions_sum.to_string(index = False)
absentions_sum
'10579843'
votans_sum = participation.loc[participation['Nom'] == 'ARTHAUD','Votants']
votans_sum = votans_sum.to_string(index = False)
votans_sum
'37010109'
blancs_sum = participation.loc[participation['Nom'] == 'ARTHAUD','Blancs']
blancs_sum = blancs_sum.to_string(index = False)
blancs_sum
'660100'
nuls_sum = participation.loc[participation['Nom'] == 'ARTHAUD','Nuls']
nuls_sum = nuls_sum.to_string(index = False)
nuls_sum
'289408'
exprimés_sum = participation.loc[participation['Nom'] == 'ARTHAUD','Exprimés']
exprimés_sum = exprimés_sum.to_string(index = False)
exprimés_sum
'36060601'
participation_ratio = data_p8_1tour.groupby('Nom').mean()
participation_ratio = participation_ratio.reset_index(drop=False)
participation_ratio.head(2)
| Nom | Code de la circonscription | Code de la commune | Inscrits | Abstentions | % Abs/Ins | Votants | % Vot/Ins | Blancs | % Blancs/Ins | % Blancs/Vot | Nuls | % Nuls/Ins | % Nuls/Vot | Exprimés | % Exp/Ins | % Exp/Vot | Voix | % Voix/Ins | % Voix/Exp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ARTHAUD | 4.1726374 | 233.8972926 | 687.1699083 | 152.7664862 | 20.2658724 | 534.4034221 | 79.7327155 | 9.5314418 | 1.48436 | 1.9010008 | 4.1788752 | 0.6642203 | 0.8900908 | 520.6931052 | 77.5841268 | 97.2060318 | 3.3561331 | 0.5392798 | 0.7143471 |
| 1 | ASSELINEAU | 4.1726374 | 233.8972926 | 687.1699083 | 152.7664862 | 20.2658724 | 534.4034221 | 79.7327155 | 9.5314418 | 1.48436 | 1.9010008 | 4.1788752 | 0.6642203 | 0.8900908 | 520.6931052 | 77.5841268 | 97.2060318 | 4.8023825 | 0.6967669 | 0.9186233 |
abs_ratio = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Abs/Ins']
abs_ratio = (round(abs_ratio, 2))
abs_ratio = abs_ratio.to_string(index = False)
abs_ratio
'20.27'
vot_ratio = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Vot/Ins']
vot_ratio = (round(vot_ratio, 2))
vot_ratio = vot_ratio.to_string(index = False)
vot_ratio
'79.73'
blancs_ratio = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Blancs/Ins']
blancs_ratio = (round(blancs_ratio, 2))
blancs_ratio = blancs_ratio.to_string(index = False)
blancs_ratio
'1.48'
blancs_ratio2 = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Blancs/Vot']
blancs_ratio2 = (round(blancs_ratio2, 2))
blancs_ratio2 = blancs_ratio2.to_string(index = False)
blancs_ratio2
'1.9'
nuls_ratio = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Nuls/Ins']
nuls_ratio = (round(nuls_ratio, 2))
nuls_ratio = nuls_ratio.to_string(index = False)
nuls_ratio
'0.66'
nuls_ratio2 = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Nuls/Vot']
nuls_ratio2 = (round(nuls_ratio2, 2))
nuls_ratio2 = nuls_ratio2.to_string(index = False)
nuls_ratio2
'0.89'
exp_ratio = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Exp/Ins']
exp_ratio = (round(exp_ratio, 2))
exp_ratio = exp_ratio.to_string(index = False)
exp_ratio
'77.58'
exp_ratio2 = participation_ratio.loc[participation_ratio['Nom'] == 'ARTHAUD','% Exp/Vot']
exp_ratio2 = (round(exp_ratio2, 2))
exp_ratio2 = exp_ratio2.to_string(index = False)
exp_ratio2
'97.21'
#Jé crée un dataframe pour le nombre d'inscrits, abstentions, votants, blancs, nuls, exprimés
participation = pd.DataFrame({'Nombre': pd.Series([inscrits_sum, absentions_sum, votans_sum,blancs_sum,nuls_sum,exprimés_sum], index = ['Inscrits', 'Abstentions', 'Votants','Blancs','Nuls','Exprimés']),
'% des inscrits': pd.Series(['',abs_ratio, vot_ratio,blancs_ratio,nuls_ratio,exp_ratio], index = ['Inscrits', 'Abstentions', 'Votants','Blancs','Nuls','Exprimés']),
'% des votants': pd.Series(['','',100,blancs_ratio2,nuls_ratio2,exp_ratio2], index = ['Inscrits', 'Abstentions', 'Votants','Blancs','Nuls','Exprimés'])})
participation
| Nombre | % des inscrits | % des votants | |
|---|---|---|---|
| Inscrits | 47589952 | ||
| Abstentions | 10579843 | 20.27 | |
| Votants | 37010109 | 79.73 | 100 |
| Blancs | 660100 | 1.48 | 1.9 |
| Nuls | 289408 | 0.66 | 0.89 |
| Exprimés | 36060601 | 77.58 | 97.21 |
# bar chart
value = [66920000,47589952,37010109,36060601,10579843,660100,289408]
labels = ['Population 2017','Inscrits','Votants','Exprimés','Abstentions','Blancs','Nuls']
#participation_viz = participation_viz.sort_values('Nombre',ascending=[False])
pio.templates.default = "plotly_white"
fig = px.bar(x=labels, y=value,width=800, height=600,text=value, labels={ "x": " ","y": "nombre de voix"})
fig.update_traces(textposition = 'outside',texttemplate='%{text:,}', textfont_size=12)
#fig.update_traces(marker_color='dimgray')
fig.update_layout(title_text='<b>Participation au 1er Tour', title_y=0.97,title_x=0.55,title_font = dict(size=25, color='dimgray'))
fig.update_layout(separators = '.,',margin=dict(t=50, b=0, l=0, r=0))
#fig.update_layout(legend=dict(yanchor="auto", y=0.5, xanchor="auto", x=1.3),legend_title_text='')
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
#fig.update_yaxes(visible=False)
fig.show()
# bar chart
value = [79.73,77.58,20.27,1.48,0.66,]
labels = ['% Vot/ins','% Exp/ins','% abs/ins','% Blancs/ins','% Nuls/ins']
#participation_viz = participation_viz.sort_values('Nombre',ascending=[False])
pio.templates.default = "plotly_white"
fig = px.bar(x=labels, y=value,width=800, height=600,text=value, labels={ "x": " ","y": "% des voix"})
fig.update_traces(textposition = 'outside',texttemplate='%{text:,}', textfont_size=12)
#fig.update_traces(marker_color='dimgray')
fig.update_layout(title_text='<b>Ratio des inscrits au 1er Tour', title_y=0.97,title_x=0.55,title_font = dict(size=25, color='dimgray'))
fig.update_layout(separators = '.,',margin=dict(t=50, b=0, l=0, r=0))
#fig.update_layout(legend=dict(yanchor="auto", y=0.5, xanchor="auto", x=1.3),legend_title_text='')
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
#fig.update_yaxes(visible=False)
fig.show()
# bar chart
value = [97.21,1.90,0.89]
labels = ['% Exp/vot','% Blancs/vot','% nuls/vot']
#participation_viz = participation_viz.sort_values('Nombre',ascending=[False])
pio.templates.default = "plotly_white"
fig = px.bar(x=labels, y=value,width=800, height=600,text=value, labels={ "x": " ","y": "% des voix"})
fig.update_traces(textposition = 'outside',texttemplate='%{text:,}', textfont_size=12)
#fig.update_traces(marker_color='dimgray')
fig.update_layout(title_text='<b>Ratio des votants au 1er Tour', title_y=0.97,title_x=0.55,title_font = dict(size=25, color='dimgray'))
fig.update_layout(separators = '.,',margin=dict(t=50, b=0, l=0, r=0))
#fig.update_layout(legend=dict(yanchor="auto", y=0.5, xanchor="auto", x=1.3),legend_title_text='')
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
#fig.update_yaxes(visible=False)
fig.show()
classement_dep_abs = data_p8_1tour.groupby('Département').mean().sort_values('% Abs/Ins',ascending=[False])
classement_dep_abs = classement_dep_abs.reset_index(drop=False)
classement_dep_abs = classement_dep_abs.drop(columns =['Code de la circonscription','Code de la commune','Votants','% Vot/Ins','Blancs','% Blancs/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_abs_top30 = classement_dep_abs.head(30)
classement_dep_abs.head(5)
| Département | Inscrits | Abstentions | % Abs/Ins | |
|---|---|---|---|---|
| 0 | Saint-Martin/Saint-Barthélemy | 1057.7083333 | 716.7500000 | 67.6683333 |
| 1 | Guyane | 808.1304348 | 530.5217391 | 66.2443478 |
| 2 | Martinique | 944.7173252 | 567.9483283 | 60.3312766 |
| 3 | Guadeloupe | 764.1183575 | 458.1980676 | 60.0515459 |
| 4 | Nouvelle-Calédonie | 701.7888889 | 363.9148148 | 58.9028148 |
abs_top_1 = classement_dep_abs.loc[classement_dep_abs['Département'] == "Saint-Martin/Saint-Barthélemy"]
abs_top_1 = abs_top_1["% Abs/Ins"]
abs_top_1 = abs_top_1.to_string(index=False)
abs_top_1 = "{0:.2f}".format(float(abs_top_1))
abs_top_1
'67.67'
abs_top_2 = classement_dep_abs.loc[classement_dep_abs['Département'] == "Guyane"]
abs_top_2 = abs_top_2["% Abs/Ins"]
abs_top_2 = abs_top_2.to_string(index=False)
abs_top_2 = "{0:.2f}".format(float(abs_top_2))
abs_top_2
'66.24'
abs_top_3 = classement_dep_abs.loc[classement_dep_abs['Département'] == "Martinique"]
abs_top_3 = abs_top_3["% Abs/Ins"]
abs_top_3 = abs_top_3.to_string(index=False)
abs_top_3 = "{0:.2f}".format(float(abs_top_3))
abs_top_3
'60.33'
# scatter plot
pio.templates.default = "plotly_white"
#text=classement_dep_blanc3['% Blancs/Vot']
#labels={ "Département": " "}
fig = px.scatter(classement_dep_abs_top30, x="Département", y="% Abs/Ins",labels={ "Département": " "})
fig.update_layout(title_text="<b>Ratio des abstentions/ département au 1er Tour", title_y=0.9,title_x=0.5,title_font = dict(size=25, color='dimgray'))
fig.update_layout(margin=dict(t=100, b=0, l=0, r=0))
#fig.update_yaxes(visible=False)
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
fig.add_annotation(x= "Saint-Martin/Saint-Barthélemy", y=abs_top_1, text=abs_top_1,xanchor='auto')
fig.add_annotation(x= "Guyane", y=abs_top_2, text=abs_top_2,xanchor='left')
fig.add_annotation(x= "Martinique", y=abs_top_3, text=abs_top_3,xanchor='left')
fig.update_layout(margin_pad=10)
#fig.update_yaxes(title=None)
fig.show()
classement_dep_abs2 = data_p8_1tour.groupby('Département').mean().sort_values('% Abs/Ins')
classement_dep_abs2 = classement_dep_abs2.reset_index(drop=False)
classement_dep_abs2 = classement_dep_abs2.drop(columns =['Code de la circonscription','Code de la commune','Votants','% Vot/Ins','Blancs','% Blancs/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_abs2.head(5)
| Département | Inscrits | Abstentions | % Abs/Ins | |
|---|---|---|---|---|
| 0 | Gers | 284.7917485 | 45.2396857 | 14.5693713 |
| 1 | Lot | 347.9291139 | 57.0025316 | 15.1133165 |
| 2 | Côtes-d'Armor | 697.1725191 | 109.5282443 | 15.4685496 |
| 3 | Ille-et-Vilaine | 840.2094361 | 134.2980437 | 15.5937399 |
| 4 | Vendée | 854.5548173 | 137.6528239 | 15.8904983 |
classement_dep_vot = data_p8_1tour.groupby('Département').mean().sort_values('% Vot/Ins',ascending=[False])
classement_dep_vot = classement_dep_vot.reset_index(drop=False)
classement_dep_vot = classement_dep_vot.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','% Abs/Ins','Blancs','% Blancs/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_vot.head(5)
| Département | Inscrits | Votants | % Vot/Ins | |
|---|---|---|---|---|
| 0 | Gers | 284.7917485 | 239.5520629 | 85.4306876 |
| 1 | Lot | 347.9291139 | 290.9265823 | 84.8867595 |
| 2 | Côtes-d'Armor | 697.1725191 | 587.6442748 | 84.5314809 |
| 3 | Ille-et-Vilaine | 840.2094361 | 705.9113924 | 84.4062716 |
| 4 | Vendée | 854.5548173 | 716.9019934 | 84.1095183 |
classement_dep_vot2 = data_p8_1tour.groupby('Département').mean().sort_values('% Vot/Ins')
classement_dep_vot2 = classement_dep_vot2.reset_index(drop=False)
classement_dep_vot2 = classement_dep_vot2.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','% Abs/Ins','Blancs','% Blancs/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_vot2_top30 = classement_dep_vot2.head(30)
classement_dep_vot2.head(5)
| Département | Inscrits | Votants | % Vot/Ins | |
|---|---|---|---|---|
| 0 | Saint-Martin/Saint-Barthélemy | 1057.7083333 | 340.9583333 | 32.3316667 |
| 1 | Guyane | 808.1304348 | 277.6086957 | 33.7556522 |
| 2 | Martinique | 944.7173252 | 376.7689970 | 39.6687234 |
| 3 | Guadeloupe | 764.1183575 | 305.9202899 | 39.9484541 |
| 4 | Nouvelle-Calédonie | 701.7888889 | 337.8740741 | 41.0972222 |
vot_top_1 = classement_dep_vot2.loc[classement_dep_vot2['Département'] == "Saint-Martin/Saint-Barthélemy"]
vot_top_1 = vot_top_1["% Vot/Ins"]
vot_top_1 = vot_top_1.to_string(index=False)
vot_top_1 = "{0:.2f}".format(float(vot_top_1))
vot_top_1
'32.33'
vot_top_2 = classement_dep_vot2.loc[classement_dep_vot2['Département'] == "Guyane"]
vot_top_2 = vot_top_2["% Vot/Ins"]
vot_top_2 = vot_top_2.to_string(index=False)
vot_top_2 = "{0:.2f}".format(float(vot_top_2))
vot_top_2
'33.76'
vot_top_3 = classement_dep_vot2.loc[classement_dep_vot2['Département'] == "Martinique"]
vot_top_3 = vot_top_3["% Vot/Ins"]
vot_top_3 = vot_top_3.to_string(index=False)
vot_top_3 = "{0:.2f}".format(float(vot_top_3))
vot_top_3
'39.67'
# scatter plot
pio.templates.default = "plotly_white"
#text=classement_dep_blanc3['% Blancs/Vot']
#labels={ "Département": " "}
fig = px.scatter(classement_dep_vot2_top30, x="Département", y="% Vot/Ins",labels={ "Département": " "})
fig.update_layout(title_text="<b>Ratio des votants/département au 1er Tour", title_y=0.9,title_x=0.5,title_font = dict(size=25, color='dimgray'))
fig.update_layout(margin=dict(t=100, b=0, l=0, r=0))
#fig.update_yaxes(visible=False)
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
fig.add_annotation(x= "Saint-Martin/Saint-Barthélemy", y=vot_top_1, text=vot_top_1,xanchor='right')
fig.add_annotation(x= "Guyane", y=vot_top_2, text=vot_top_2,xanchor='auto')
fig.add_annotation(x= "Martinique", y=vot_top_3, text=vot_top_3,xanchor='auto')
fig.update_layout(margin_pad=10)
fig.show()
classement_dep_blanc = data_p8_1tour.groupby('Département').mean().sort_values('% Blancs/Ins',ascending=[False])
classement_dep_blanc = classement_dep_blanc.reset_index(drop=False)
classement_dep_blanc = classement_dep_blanc.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_blanc.head(5)
| Département | Inscrits | Blancs | % Blancs/Ins | |
|---|---|---|---|---|
| 0 | Guyane | 808.1304348 | 33.3130435 | 3.9444348 |
| 1 | Martinique | 944.7173252 | 24.7781155 | 2.6247112 |
| 2 | Creuse | 329.6338028 | 6.8838028 | 2.2168310 |
| 3 | Corrèze | 482.4921875 | 8.9296875 | 1.9410417 |
| 4 | Cantal | 396.7060811 | 7.1385135 | 1.9065878 |
classement_dep_blanc2 = data_p8_1tour.groupby('Département').mean().sort_values('% Blancs/Ins')
classement_dep_blanc2 = classement_dep_blanc2.reset_index(drop=False)
classement_dep_blanc2 = classement_dep_blanc2.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_blanc2.head(5)
| Département | Inscrits | Blancs | % Blancs/Ins | |
|---|---|---|---|---|
| 0 | Français établis hors de France | 5668.6681614 | 14.2107623 | 0.3900897 |
| 1 | Wallis et Futuna | 8464.0000000 | 35.0000000 | 0.4100000 |
| 2 | Paris | 1452.7198661 | 11.8604911 | 0.8103571 |
| 3 | Saint-Martin/Saint-Barthélemy | 1057.7083333 | 8.7916667 | 0.8183333 |
| 4 | Polynésie française | 864.1525424 | 8.1737288 | 0.9349153 |
classement_dep_blanc3 = data_p8_1tour.groupby('Département').mean().sort_values('% Blancs/Vot',ascending=[False])
classement_dep_blanc3 = classement_dep_blanc3.reset_index(drop=False)
classement_dep_blanc3 = classement_dep_blanc3.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','% Abs/Ins','Inscrits','% Vot/Ins','% Blancs/Ins','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_blanc3_top30 = classement_dep_blanc3.head(30)
classement_dep_blanc3.head(5)
| Département | Votants | Blancs | % Blancs/Vot | |
|---|---|---|---|---|
| 0 | Guyane | 277.6086957 | 33.3130435 | 11.3906957 |
| 1 | Martinique | 376.7689970 | 24.7781155 | 6.8223404 |
| 2 | Guadeloupe | 305.9202899 | 13.5990338 | 4.5214251 |
| 3 | Nouvelle-Calédonie | 337.8740741 | 10.9962963 | 3.2305185 |
| 4 | La Réunion | 414.1854305 | 12.6578366 | 3.0547020 |
top_1 = classement_dep_blanc3.loc[classement_dep_blanc3['Département'] == "Guyane"]
top_1 = top_1["% Blancs/Vot"]
top_1 = top_1.to_string(index=False)
top_1 = "{0:.2f}".format(float(top_1))
top_1
'11.39'
top_2 = classement_dep_blanc3.loc[classement_dep_blanc3['Département'] == "Martinique"]
top_2 = top_2["% Blancs/Vot"]
top_2 = top_2.to_string(index=False)
top_2 = "{0:.2f}".format(float(top_2))
top_2
'6.82'
top_3 = classement_dep_blanc3.loc[classement_dep_blanc3['Département'] == "Guadeloupe"]
top_3 = top_3["% Blancs/Vot"]
top_3 = top_3.to_string(index=False)
top_3 = "{0:.2f}".format(float(top_3))
top_3
'4.52'
# scatter plot
pio.templates.default = "plotly_white"
#text=classement_dep_blanc3['% Blancs/Vot']
#labels={ "Département": " "}
fig = px.scatter(classement_dep_blanc3_top30, x="Département", y="% Blancs/Vot",labels={ "Département": " "})
fig.update_layout(title_text="<b>Ratio de votes blancs/votants par département au 1er Tour", title_y=0.9,title_x=0.5,title_font = dict(size=25, color='dimgray'))
fig.update_layout(margin=dict(t=100, b=0, l=0, r=0))
#fig.update_yaxes(visible=False)
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
fig.add_annotation(x= "Guyane", y=top_1, text=top_1)
fig.add_annotation(x= "Martinique", y=top_2, text=top_2)
fig.add_annotation(x= "Guadeloupe", y=top_3, text=top_3)
fig.show()
classement_dep_blanc4 = data_p8_1tour.groupby('Département').mean().sort_values('% Blancs/Vot')
classement_dep_blanc4 = classement_dep_blanc4.reset_index(drop=False)
classement_dep_blanc4 = classement_dep_blanc4.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','% Abs/Ins','Inscrits','% Vot/Ins','% Blancs/Ins','Nuls','% Nuls/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_blanc4.head(5)
| Département | Votants | Blancs | % Blancs/Vot | |
|---|---|---|---|---|
| 0 | Wallis et Futuna | 5411.0000000 | 35.0000000 | 0.6500000 |
| 1 | Français établis hors de France | 2510.0000000 | 14.2107623 | 0.8304933 |
| 2 | Paris | 1218.1216518 | 11.8604911 | 0.9766295 |
| 3 | Yvelines | 787.0427263 | 11.0254323 | 1.4496643 |
| 4 | Alpes-Maritimes | 617.1378601 | 9.3508230 | 1.5270988 |
classement_dep_nul = data_p8_1tour.groupby('Département').mean().sort_values('% Nuls/Ins',ascending=[False])
classement_dep_nul = classement_dep_nul.reset_index(drop=False)
classement_dep_nul = classement_dep_nul.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_nul.head(5)
| Département | Inscrits | Nuls | % Nuls/Ins | |
|---|---|---|---|---|
| 0 | Guadeloupe | 764.1183575 | 21.2053140 | 2.7995169 |
| 1 | Mayotte | 471.8579545 | 12.1136364 | 2.6517614 |
| 2 | Martinique | 944.7173252 | 19.8814590 | 2.1174772 |
| 3 | La Réunion | 705.8289183 | 14.6843267 | 2.0830022 |
| 4 | Guyane | 808.1304348 | 10.9130435 | 1.5002609 |
classement_dep_nul2 = data_p8_1tour.groupby('Département').mean().sort_values('% Nuls/Ins')
classement_dep_nul2 = classement_dep_nul2.reset_index(drop=False)
classement_dep_nul2 = classement_dep_nul2.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_nul2.head(5)
| Département | Inscrits | Nuls | % Nuls/Ins | |
|---|---|---|---|---|
| 0 | Français établis hors de France | 5668.6681614 | 10.9506726 | 0.2149776 |
| 1 | Hauts-de-Seine | 973.1065089 | 2.5325444 | 0.2661538 |
| 2 | Paris | 1452.7198661 | 4.7444196 | 0.3255915 |
| 3 | Wallis et Futuna | 8464.0000000 | 28.0000000 | 0.3300000 |
| 4 | Alpes-Maritimes | 783.7047325 | 2.9187243 | 0.3941975 |
classement_dep_nul3 = data_p8_1tour.groupby('Département').mean().sort_values('% Nuls/Vot',ascending=[False])
classement_dep_nul3 = classement_dep_nul3.reset_index(drop=False)
classement_dep_nul3 = classement_dep_nul3.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Inscrits','% Vot/Ins','% Blancs/Vot','% Nuls/Ins','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_nul3_top30 = classement_dep_nul3.head(30)
classement_dep_nul3.head(5)
| Département | Votants | Nuls | % Nuls/Vot | |
|---|---|---|---|---|
| 0 | Guadeloupe | 305.9202899 | 21.2053140 | 6.7432126 |
| 1 | Mayotte | 205.6079545 | 12.1136364 | 6.0645455 |
| 2 | Martinique | 376.7689970 | 19.8814590 | 5.5373556 |
| 3 | Guyane | 277.6086957 | 10.9130435 | 4.4500000 |
| 4 | La Réunion | 414.1854305 | 14.6843267 | 3.6286755 |
nul_top_1 = classement_dep_nul3.loc[classement_dep_nul3['Département'] == "Guadeloupe"]
nul_top_1 = nul_top_1["% Nuls/Vot"]
nul_top_1 = nul_top_1.to_string(index=False)
nul_top_1 = "{0:.2f}".format(float(nul_top_1))
nul_top_1
'6.74'
nul_top_2 = classement_dep_nul3.loc[classement_dep_nul3['Département'] == "Mayotte"]
nul_top_2 = nul_top_2["% Nuls/Vot"]
nul_top_2 = nul_top_2.to_string(index=False)
nul_top_2 = "{0:.2f}".format(float(nul_top_2))
nul_top_2
'6.06'
nul_top_3 = classement_dep_nul3.loc[classement_dep_nul3['Département'] == "Martinique"]
nul_top_3 = nul_top_3["% Nuls/Vot"]
nul_top_3 = nul_top_3.to_string(index=False)
nul_top_3 = "{0:.2f}".format(float(nul_top_3))
nul_top_3
'5.54'
# scatter plot
pio.templates.default = "plotly_white"
#text=classement_dep_blanc3['% Blancs/Vot']
#labels={ "Département": " "}
fig = px.scatter(classement_dep_nul3_top30, x="Département", y="% Nuls/Vot",labels={ "Département": " "})
fig.update_layout(title_text="<b>Ratio de votes nuls/votants par département au 1er Tour", title_y=0.9,title_x=0.5,title_font = dict(size=25, color='dimgray'))
fig.update_layout(margin=dict(t=100, b=0, l=0, r=0))
#fig.update_yaxes(visible=False)
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
fig.add_annotation(x= "Guadeloupe", y=nul_top_1, text=nul_top_1)
fig.add_annotation(x= "Mayotte", y=nul_top_2, text=nul_top_2)
fig.add_annotation(x= "Martinique", y=nul_top_3, text=nul_top_3)
fig.show()
classement_dep_nul4 = data_p8_1tour.groupby('Département').mean().sort_values('% Nuls/Vot')
classement_dep_nul4 = classement_dep_nul4.reset_index(drop=False)
classement_dep_nul4 = classement_dep_nul4.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Inscrits','% Vot/Ins','% Blancs/Vot','% Nuls/Ins','Exprimés','% Exp/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_nul4.head(5)
| Département | Votants | Nuls | % Nuls/Vot | |
|---|---|---|---|---|
| 0 | Hauts-de-Seine | 798.8313609 | 2.5325444 | 0.3345168 |
| 1 | Paris | 1218.1216518 | 4.7444196 | 0.3953906 |
| 2 | Alpes-Maritimes | 617.1378601 | 2.9187243 | 0.5016461 |
| 3 | Français établis hors de France | 2510.0000000 | 10.9506726 | 0.5071749 |
| 4 | Wallis et Futuna | 5411.0000000 | 28.0000000 | 0.5200000 |
classement_dep_exp = data_p8_1tour.groupby('Département').mean().sort_values('% Exp/Ins',ascending=[False])
classement_dep_exp = classement_dep_exp.reset_index(drop=False)
classement_dep_exp = classement_dep_exp.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Nuls','% Nuls/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_exp.head(5)
| Département | Inscrits | Exprimés | % Exp/Ins | |
|---|---|---|---|---|
| 0 | Gers | 284.7917485 | 233.1689587 | 83.0792141 |
| 1 | Paris | 1452.7198661 | 1201.5167411 | 82.7429799 |
| 2 | Côtes-d'Armor | 697.1725191 | 573.3160305 | 82.4526107 |
| 3 | Ille-et-Vilaine | 840.2094361 | 689.6904488 | 82.4045685 |
| 4 | Lot | 347.9291139 | 282.8050633 | 82.3255696 |
classement_dep_exp2 = data_p8_1tour.groupby('Département').mean().sort_values('% Exp/Ins')
classement_dep_exp2 = classement_dep_exp2.reset_index(drop=False)
classement_dep_exp2 = classement_dep_exp2.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Nuls','% Nuls/Ins','% Exp/Vot','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_exp2_top30 = classement_dep_exp2.head(30)
classement_dep_exp2.head(5)
| Département | Inscrits | Exprimés | % Exp/Ins | |
|---|---|---|---|---|
| 0 | Guyane | 808.1304348 | 233.3826087 | 28.3105217 |
| 1 | Saint-Martin/Saint-Barthélemy | 1057.7083333 | 327.7083333 | 31.0945833 |
| 2 | Martinique | 944.7173252 | 332.1094225 | 34.9265350 |
| 3 | Guadeloupe | 764.1183575 | 271.1159420 | 35.3720773 |
| 4 | Nouvelle-Calédonie | 701.7888889 | 322.0222222 | 39.1228148 |
exp_top_1 = classement_dep_exp2.loc[classement_dep_exp2['Département'] == "Guyane"]
exp_top_1 = exp_top_1["% Exp/Ins"]
exp_top_1 = exp_top_1.to_string(index=False)
exp_top_1 = "{0:.2f}".format(float(exp_top_1))
exp_top_1
'28.31'
exp_top_2 = classement_dep_exp2.loc[classement_dep_exp2['Département'] == "Saint-Martin/Saint-Barthélemy"]
exp_top_2 = exp_top_2["% Exp/Ins"]
exp_top_2 = exp_top_2.to_string(index=False)
exp_top_2 = "{0:.2f}".format(float(exp_top_2))
exp_top_2
'31.09'
exp_top_3 = classement_dep_exp2.loc[classement_dep_exp2['Département'] == "Martinique"]
exp_top_3 = exp_top_3["% Exp/Ins"]
exp_top_3 = exp_top_3.to_string(index=False)
exp_top_3 = "{0:.2f}".format(float(exp_top_3))
exp_top_3
'34.93'
# scatter plot
pio.templates.default = "plotly_white"
#text=classement_dep_blanc3['% Blancs/Vot']
#labels={ "Département": " "}
fig = px.scatter(classement_dep_exp2_top30, x="Département", y="% Exp/Ins",labels={ "Département": " "})
fig.update_layout(title_text="<b>Ratio des exprimés/département au 1er Tour", title_y=0.9,title_x=0.5,title_font = dict(size=25, color='dimgray'))
fig.update_layout(margin=dict(t=100, b=0, l=0, r=0))
#fig.update_yaxes(visible=False)
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
fig.add_annotation(x= "Guyane", y=exp_top_1, text=exp_top_1)
fig.add_annotation(x= "Saint-Martin/Saint-Barthélemy", y=exp_top_2, text=exp_top_2)
fig.add_annotation(x= "Martinique", y=exp_top_3, text=exp_top_3)
fig.show()
classement_dep_exp3 = data_p8_1tour.groupby('Département').mean().sort_values('% Exp/Vot',ascending=[False])
classement_dep_exp3 = classement_dep_exp3.reset_index(drop=False)
classement_dep_exp3 = classement_dep_exp3.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Nuls','% Nuls/Ins','% Exp/Ins','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_exp3.head(5)
| Département | Inscrits | Exprimés | % Exp/Vot | |
|---|---|---|---|---|
| 0 | Wallis et Futuna | 8464.0000000 | 5348.0000000 | 98.8400000 |
| 1 | Paris | 1452.7198661 | 1201.5167411 | 98.6279911 |
| 2 | Hauts-de-Seine | 973.1065089 | 783.7850099 | 98.0687574 |
| 3 | Yvelines | 967.5971516 | 772.0590031 | 98.0258291 |
| 4 | Alpes-Maritimes | 783.7047325 | 604.8683128 | 97.9711523 |
classement_dep_exp4 = data_p8_1tour.groupby('Département').mean().sort_values('% Exp/Vot')
classement_dep_exp4 = classement_dep_exp4.reset_index(drop=False)
classement_dep_exp4 = classement_dep_exp4.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Nuls','% Nuls/Ins','% Exp/Ins','Voix','% Voix/Ins','% Voix/Exp'])
classement_dep_exp4.head(5)
| Département | Inscrits | Exprimés | % Exp/Vot | |
|---|---|---|---|---|
| 0 | Guyane | 808.1304348 | 233.3826087 | 84.1586087 |
| 1 | Martinique | 944.7173252 | 332.1094225 | 87.6401520 |
| 2 | Guadeloupe | 764.1183575 | 271.1159420 | 88.7354589 |
| 3 | Mayotte | 471.8579545 | 188.2386364 | 91.3994318 |
| 4 | La Réunion | 705.8289183 | 386.8432671 | 93.3166887 |
participation2 = data_p8_1tour.groupby('Nom').sum().sort_values('Voix',ascending=[False])
participation2 = participation2.reset_index(drop=False)
participation2 = participation2.drop(columns =['Code de la circonscription','Code de la commune','Abstentions','Blancs','% Blancs/Ins','% Abs/Ins','Votants','% Vot/Ins','% Blancs/Vot','% Nuls/Vot','Nuls','% Nuls/Ins','% Exp/Vot','% Exp/Ins','% Voix/Ins','% Voix/Exp'])
participation2.head(11)
| Nom | Inscrits | Exprimés | Voix | |
|---|---|---|---|---|
| 0 | MACRON | 47589952 | 36060601 | 8657749 |
| 1 | LE PEN | 47589952 | 36060601 | 7679914 |
| 2 | FILLON | 47589952 | 36060601 | 7214181 |
| 3 | MÉLENCHON | 47589952 | 36060601 | 7061130 |
| 4 | HAMON | 47589952 | 36060601 | 2291688 |
| 5 | DUPONT-AIGNAN | 47589952 | 36060601 | 1695311 |
| 6 | LASSALLE | 47589952 | 36060601 | 435432 |
| 7 | POUTOU | 47589952 | 36060601 | 394575 |
| 8 | ASSELINEAU | 47589952 | 36060601 | 332589 |
| 9 | ARTHAUD | 47589952 | 36060601 | 232429 |
| 10 | CHEMINADE | 47589952 | 36060601 | 65603 |
participation2['ratio_inscrits'] = round((participation2['Voix'] / participation2['Inscrits'])*100,2)
participation2['ratio_exprimés'] = round((participation2['Voix'] / participation2['Exprimés'])*100,2)
participation2 = participation2.drop(columns =['Inscrits','Exprimés'])
participation2.head(11)
| Nom | Voix | ratio_inscrits | ratio_exprimés | |
|---|---|---|---|---|
| 0 | MACRON | 8657749 | 18.19 | 24.01 |
| 1 | LE PEN | 7679914 | 16.14 | 21.30 |
| 2 | FILLON | 7214181 | 15.16 | 20.01 |
| 3 | MÉLENCHON | 7061130 | 14.84 | 19.58 |
| 4 | HAMON | 2291688 | 4.82 | 6.36 |
| 5 | DUPONT-AIGNAN | 1695311 | 3.56 | 4.70 |
| 6 | LASSALLE | 435432 | 0.91 | 1.21 |
| 7 | POUTOU | 394575 | 0.83 | 1.09 |
| 8 | ASSELINEAU | 332589 | 0.70 | 0.92 |
| 9 | ARTHAUD | 232429 | 0.49 | 0.64 |
| 10 | CHEMINADE | 65603 | 0.14 | 0.18 |
# pie chart
fig = px.pie(participation2, values='ratio_exprimés', names='Nom',width=700, height=600, hole=0.5, color = 'Nom',color_discrete_map={
'MACRON':'deeppink',
'LE PEN':'darkblue',
'FILLON':'dodgerblue',
'MÉLENCHON':'darkorange',
'HAMON':'pink',
'DUPONT-AIGNAN':'sienna',
'LASSALLE':'darkcyan',
'POUTOU':'crimson',
'ASSELINEAU':'mediumaquamarine',
'ARTHAUD':'khaki',
'CHEMINADE':'peachpuff'})
fig.update_traces(textposition = 'inside',textfont_size=12, textinfo='percent+label',pull=[0.2,0,0,0,0,0,0,0,0,0,0],marker = dict(line=dict(color='white', width=3)))
fig.update_layout(title_text='<b>Ratio des votes/candidat au 1er Tour', title_y=0.97,title_x=0.55,title_font = dict(size=25, color='dimgray'))
fig.update_layout(legend=dict(yanchor="auto", y=0.5, xanchor="auto", x=1.3))
fig.update_layout(margin=dict(t=70, b=0, l=0, r=0))
fig.show()
# bar chart
pio.templates.default = "plotly_white"
fig = px.bar(participation2, x='Nom', y='Voix',width=800, height=500, text="Voix", labels={ "Voix": "Nombre de voix","Nom": ""},color = 'Nom',color_discrete_map={
'MACRON':'deeppink',
'LE PEN':'darkblue',
'FILLON':'dodgerblue',
'MÉLENCHON':'darkorange',
'HAMON':'pink',
'DUPONT-AIGNAN':'sienna',
'LASSALLE':'darkcyan',
'POUTOU':'crimson',
'ASSELINEAU':'mediumaquamarine',
'ARTHAUD':'khaki',
'CHEMINADE':'peachpuff'})
fig.update_traces(textposition = 'outside',texttemplate='%{text:,}', textfont_size=12)
fig.update_layout(title_text='<b>Nombre de votes/candidat au 1er Tour', title_y=0.97,title_x=0.55,title_font = dict(size=25, color='dimgray'))
fig.update_layout(legend=dict(yanchor="auto", y=0.5, xanchor="auto", x=1.3),legend_title_text='')
fig.update_layout(separators = '.,',margin=dict(t=70, b=0, l=0, r=0))
#fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',plot_bgcolor='rgba(0,0,0,0)')
fig.update_yaxes(visible=False)
fig.show()
rank = data_p8_1tour.groupby(['Département','Code du département','Nom']).sum()
rank = rank.drop(columns =['% Nuls/Ins','Nuls','% Blancs/Vot','Code de la circonscription','Code de la commune','Inscrits','Abstentions','% Abs/Ins','Votants','% Vot/Ins','Blancs','% Blancs/Ins','% Nuls/Vot','Exprimés','% Exp/Ins','% Exp/Vot','% Voix/Ins','% Voix/Exp'])
rank = rank.reset_index(drop=False)
rank.head(11)
| Département | Code du département | Nom | Voix | |
|---|---|---|---|---|
| 0 | Ain | 01 | ARTHAUD | 1842 |
| 1 | Ain | 01 | ASSELINEAU | 3612 |
| 2 | Ain | 01 | CHEMINADE | 595 |
| 3 | Ain | 01 | DUPONT-AIGNAN | 19788 |
| 4 | Ain | 01 | FILLON | 69805 |
| 5 | Ain | 01 | HAMON | 16711 |
| 6 | Ain | 01 | LASSALLE | 3465 |
| 7 | Ain | 01 | LE PEN | 81455 |
| 8 | Ain | 01 | MACRON | 73692 |
| 9 | Ain | 01 | MÉLENCHON | 51736 |
| 10 | Ain | 01 | POUTOU | 3098 |
Dep = rank['Département'].unique()
len(Dep)
107
Vainqueurs = pd.DataFrame()
for i in Dep :
each_dep = rank.loc[(rank['Département'] == i)]
each_win = each_dep[each_dep['Voix'] == each_dep['Voix'].max()]
Vainqueurs = Vainqueurs.append(each_win)
Vainqueurs
| Département | Code du département | Nom | Voix | |
|---|---|---|---|---|
| 7 | Ain | 01 | LE PEN | 81455 |
| 18 | Aisne | 02 | LE PEN | 102770 |
| 30 | Allier | 03 | MACRON | 45651 |
| 40 | Alpes-Maritimes | 06 | LE PEN | 163141 |
| 51 | Alpes-de-Haute-Provence | 04 | LE PEN | 24463 |
| 62 | Ardennes | 08 | LE PEN | 47578 |
| 73 | Ardèche | 07 | LE PEN | 45305 |
| 86 | Ariège | 09 | MÉLENCHON | 24970 |
| 95 | Aube | 10 | LE PEN | 48846 |
| 106 | Aude | 11 | LE PEN | 60585 |
| 118 | Aveyron | 12 | MACRON | 45584 |
| 128 | Bas-Rhin | 67 | LE PEN | 147714 |
| 139 | Bouches-du-Rhône | 13 | LE PEN | 286397 |
| 151 | Calvados | 14 | MACRON | 99720 |
| 162 | Cantal | 15 | MACRON | 24477 |
| 173 | Charente | 16 | MACRON | 49889 |
| 184 | Charente-Maritime | 17 | MACRON | 91355 |
| 194 | Cher | 18 | LE PEN | 41882 |
| 206 | Corrèze | 19 | MACRON | 39218 |
| 216 | Corse-du-Sud | 2A | LE PEN | 20858 |
| 228 | Creuse | 23 | MACRON | 15885 |
| 239 | Côte-d'Or | 21 | MACRON | 67436 |
| 250 | Côtes-d'Armor | 22 | MACRON | 105069 |
| 261 | Deux-Sèvres | 79 | MACRON | 57826 |
| 273 | Dordogne | 24 | MÉLENCHON | 57132 |
| 282 | Doubs | 25 | LE PEN | 66635 |
| 293 | Drôme | 26 | LE PEN | 68996 |
| 305 | Essonne | 91 | MACRON | 163389 |
| 315 | Eure | 27 | LE PEN | 98719 |
| 326 | Eure-et-Loir | 28 | LE PEN | 58886 |
| 338 | Finistère | 29 | MACRON | 164095 |
| 349 | Français établis hors de France | ZZ | MACRON | 223879 |
| 359 | Gard | 30 | LE PEN | 123273 |
| 371 | Gers | 32 | MACRON | 27775 |
| 382 | Gironde | 33 | MACRON | 222493 |
| 393 | Guadeloupe | 971 | MACRON | 33930 |
| 405 | Guyane | 973 | MÉLENCHON | 6633 |
| 414 | Haut-Rhin | 68 | LE PEN | 109704 |
| 425 | Haute-Corse | 2B | LE PEN | 22183 |
| 437 | Haute-Garonne | 31 | MACRON | 190368 |
| 448 | Haute-Loire | 43 | MACRON | 32864 |
| 458 | Haute-Marne | 52 | LE PEN | 34027 |
| 466 | Haute-Savoie | 74 | FILLON | 105057 |
| 480 | Haute-Saône | 70 | LE PEN | 43753 |
| 492 | Haute-Vienne | 87 | MACRON | 55577 |
| 503 | Hautes-Alpes | 05 | MACRON | 18948 |
| 514 | Hautes-Pyrénées | 65 | MACRON | 35121 |
| 525 | Hauts-de-Seine | 92 | MACRON | 256687 |
| 535 | Hérault | 34 | LE PEN | 161119 |
| 547 | Ille-et-Vilaine | 35 | MACRON | 181373 |
| 557 | Indre | 36 | LE PEN | 31985 |
| 569 | Indre-et-Loire | 37 | MACRON | 83165 |
| 580 | Isère | 38 | MACRON | 164091 |
| 590 | Jura | 39 | LE PEN | 36110 |
| 603 | La Réunion | 974 | MÉLENCHON | 85987 |
| 613 | Landes | 40 | MACRON | 61043 |
| 623 | Loir-et-Cher | 41 | LE PEN | 48662 |
| 634 | Loire | 42 | LE PEN | 94222 |
| 646 | Loire-Atlantique | 44 | MACRON | 232602 |
| 656 | Loiret | 45 | LE PEN | 83662 |
| 668 | Lot | 46 | MACRON | 29762 |
| 678 | Lot-et-Garonne | 47 | LE PEN | 47271 |
| 686 | Lozère | 48 | FILLON | 10986 |
| 701 | Maine-et-Loire | 49 | MACRON | 121685 |
| 712 | Manche | 50 | MACRON | 74956 |
| 722 | Marne | 51 | LE PEN | 82473 |
| 735 | Martinique | 972 | MÉLENCHON | 29903 |
| 741 | Mayenne | 53 | FILLON | 48772 |
| 752 | Mayotte | 976 | FILLON | 10808 |
| 766 | Meurthe-et-Moselle | 54 | LE PEN | 98194 |
| 777 | Meuse | 55 | LE PEN | 34602 |
| 789 | Morbihan | 56 | MACRON | 130639 |
| 799 | Moselle | 57 | LE PEN | 158542 |
| 810 | Nièvre | 58 | LE PEN | 29817 |
| 821 | Nord | 59 | LE PEN | 382030 |
| 829 | Nouvelle-Calédonie | 988 | FILLON | 27065 |
| 843 | Oise | 60 | LE PEN | 135188 |
| 851 | Orne | 61 | FILLON | 41084 |
| 866 | Paris | 75 | MACRON | 375006 |
| 876 | Pas-de-Calais | 62 | LE PEN | 286147 |
| 884 | Polynésie française | 987 | FILLON | 26679 |
| 899 | Puy-de-Dôme | 63 | MACRON | 96892 |
| 910 | Pyrénées-Atlantiques | 64 | MACRON | 103958 |
| 920 | Pyrénées-Orientales | 66 | LE PEN | 80169 |
| 932 | Rhône | 69 | MACRON | 236137 |
| 939 | Saint-Martin/Saint-Barthélemy | 978 | FILLON | 2518 |
| 955 | Saint-Pierre-et-Miquelon | 975 | MÉLENCHON | 933 |
| 961 | Sarthe | 72 | FILLON | 92261 |
| 976 | Savoie | 73 | MACRON | 55871 |
| 986 | Saône-et-Loire | 71 | LE PEN | 75258 |
| 997 | Seine-Maritime | 76 | LE PEN | 170945 |
| 1010 | Seine-Saint-Denis | 93 | MÉLENCHON | 184123 |
| 1020 | Seine-et-Marne | 77 | MACRON | 157314 |
| 1030 | Somme | 80 | LE PEN | 97134 |
| 1041 | Tarn | 81 | LE PEN | 52402 |
| 1052 | Tarn-et-Garonne | 82 | LE PEN | 39183 |
| 1063 | Territoire de Belfort | 90 | LE PEN | 19249 |
| 1075 | Val-d'Oise | 95 | MACRON | 138752 |
| 1086 | Val-de-Marne | 94 | MACRON | 172202 |
| 1096 | Var | 83 | LE PEN | 186376 |
| 1107 | Vaucluse | 84 | LE PEN | 95930 |
| 1119 | Vendée | 85 | MACRON | 109989 |
| 1130 | Vienne | 86 | MACRON | 59146 |
| 1140 | Vosges | 88 | LE PEN | 63924 |
| 1152 | Wallis et Futuna | 986 | MACRON | 1630 |
| 1162 | Yonne | 89 | LE PEN | 52640 |
| 1174 | Yvelines | 78 | MACRON | 219063 |
#Vainqueurs.to_csv("D:/DA_P8/CSV/Vainqueurs_tour1.csv",index=False,encoding='utf-8-sig')
Count = Vainqueurs['Nom'].value_counts()
Count = Count.reset_index(drop=False)
Count = Count.rename(columns ={'index':'candidat'})
Count = Count.rename(columns ={'Nom':'nbr_département'})
Count
| candidat | nbr_département | |
|---|---|---|
| 0 | LE PEN | 47 |
| 1 | MACRON | 44 |
| 2 | FILLON | 9 |
| 3 | MÉLENCHON | 7 |